// src/main.c
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <pthread.h>
#include "asm_memcpy.h"
#include "math.h"
#include "simd.h"
#include "io.h"
#include "fault.h"
#include "object_model.hpp"
#include "exception_test.hpp"
#include "template_test.hpp"
#include "stl_test.hpp"

void sig_handler(int sig) {
    printf("Caught signal %d\n", sig);
    exit(1);
}

void *thread_func(void *arg) {
    printf("Thread running on %s\n", 
#ifdef __aarch64__
           "ARM64"
#else
           "x86_64"
#endif
    );
    return NULL;
}

int main() {
    signal(SIGINT,  sig_handler);
    signal(SIGSEGV, sig_handler);

    pthread_t tid;
    pthread_create(&tid, NULL, thread_func, NULL);
    pthread_join(tid, NULL);

    // 测试各模块
    math_test();
    simd_test();
    io_test();
    fault_test();

    // 汇编 memcpy
    char src[] = "ARM64 memcpy test";
    char dst[32];
    asm_memcpy(dst, src, sizeof(src));
    printf("Copied string: %s\n", dst);

    object_model_test();
    exception_test();
    template_test();
    stl_test();

    return 0;
}